'''
Button
按钮用来执行用户的单击操作，可以包含文本，也可以包含图像，
被单击后会自动调用对应事件绑定的方法，
b = Button(master, text ="Help", state=DISABLED))禁用按钮
anchor = N,NE,E,SE,S,SW,W,NW or CENTER表明按钮在窗口的位置


Entry单行文本框
用来接受一行字符串的控件，如果用户输入的长度长于Entry控件的长度时，
文字会自动向后滚动，需要多行文本时，需要使用text
'''
from tkinter import *
from tkinter import messagebox


class Application(Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.label01 = Label(self,text="用户名")
        self.label01.pack()

        v1 = StringVar(self)
        self.entry01 = Entry(self,textvariable=v1)
        self.entry01.pack()
        v1.set("admin")

        self.label02 = Label(self, text="密码")
        self.label02.pack()

        v2 = StringVar(self)
        self.entry02 = Entry(self, textvariable=v2, show="*")
        self.entry02.pack()
        v2.set("123456")

        self.buttonin = Button(self, text="登录", command=self.login)
        self.buttonin.pack()

        self.buttonquit = Button(self,text="退出",command=root.destroy)
        self.buttonquit.pack()
    def login(self):
        usrname = self.entry01.get()
        pwd = self.entry02.get()
        print("用户名：",usrname)
        print("密码：",pwd)
        if usrname == "admin" and pwd == "123456":
         messagebox.showinfo("系统","登录成功")
         root.destroy()
        else:
         messagebox.showinfo("系统", "登录失败")
if __name__ == '__main__':
    root = Tk()
    root.geometry("200x160+200+300")
    app = Application(master = root)
    app.mainloop()